package com.gf.message.service;

import com.gf.base.type.MessageType;
import com.gf.common.bean.Page;

public interface MessageService {

	/**
	 * 单发消息
	 * 
	 * @param senderId
	 * @param receiveID
	 * @param title
	 * @param content
	 * @param messageType
	 * @param messageState
	 * @return
	 */
	public long sendMessageByOne(long senderId, String senderName,
			long receiveId, String title, String content);

	/**
	 * 群发消息
	 * 
	 * @param senderId
	 * @param senderName
	 * @param receiveIds
	 * @param title
	 * @param content
	 * @return 插入的条数
	 */
	public int sendMessageByGroup(long senderId, String senderName,
			Long[] receiveIds, String title, String content);

	/**
	 * 得到自己发送的所有邮件
	 * 
	 * @param senderID
	 * @param curpage
	 *            从1开始，而不是0
	 * @return
	 */
	public Page getAllSendMessages(long senderId, int curpage, int pageSize);

	/**
	 * 得到草稿箱里的邮件
	 * 
	 * @param senderID
	 * @param curpage
	 *            从1开始，而不是0
	 * @return
	 */
	public Page getAllDraftMessages(long senderId, int curpage, int pageSize);

	/**
	 * 得到接收到的所有邮件
	 * 
	 * @param receiveID
	 * @param curpage
	 *            从1开始，而不是0
	 * @return
	 */
	public Page getAllReceiveMessages(long receiveId, int curpage, int pageSize);

	/**
	 * 发送者删除邮件
	 * 
	 * @param id
	 */
	public void deleteMessageBySender(long senderId);
	
	
	/**
	 * 接收者删除邮件
	 * 
	 * @param id
	 */
	public void deleteMessageByReceiver(long receiverId);
	

	/**
	 * 消息由未读变为已读
	 * 
	 * @param id
	 */
	public void messageReaded(long id);

	/**
	 * 得到未读消息的数量
	 * 
	 * @param receiveId
	 * @return
	 */
	public int getNumberOfUnreadMessages(long receiveId);

	/**
	 * 保存为草稿<br>
	 * 由于 数据库Message设计的局限性<br>
	 * 当保存为草稿时 receiveId = senderId, senderName=receiveName<br>
	 * draftReceiveIds 保存着要接收的联系人ID： 3-4-12
	 * 
	 * @return
	 */
	public long saveAsDraft(long senderId, String senderName,
			String draftReceiveIds, String draftReceiveNames, String title,
			String content);
	/**
	 * 得到全部的收到的信息
	 * 
	 * @param receiveId
	 * @return
	 */
	public int getNumberOfReceiveMessages(long receiveId);

	/**
	 * 得到自己发送或草稿的消息总数
	 * 
	 * @param senderID
	 * @return
	 */
	public int getNumberByMessageType(long senderId, MessageType messageType);
	/**
	 * 删除草稿
	 * @param id
	 */
	public void deleteDraft(long id);
}
